import '../../main.js'


// 页面加载时恢复上次选中的状态
document.addEventListener("DOMContentLoaded", function () {
    console.log("DOMContentLoaded")
    const selected = localStorage.getItem("selectedTab");
    if (selected === "admin") {
        selectTab("admin");
    } else {
        selectTab("user");
    }
});

function selectTab(tab) {
    console.log("selectTab")

    const userLi = document.getElementById("user-login");
    const adminLi = document.getElementById("admin-login");

    // 清除所有选中样式
    userLi.classList.remove("bg-blue-500", "text-blue-400");
    adminLi.classList.remove("bg-blue-500", "text-white");

    if (tab === "user") {
        userLi.classList.add("bg-blue-500", "text-white");
        localStorage.setItem("selectedTab", "user");
    } else if (tab === "admin") {
        adminLi.classList.add("bg-blue-500", "text-white");
        localStorage.setItem("selectedTab", "admin");
    }
}